<template>
  <div class="noticeAll">
    <mt-header title="公告栏">
      <mt-button icon="back" slot="left" @click="goback">返回</mt-button>
    </mt-header>
    <div class="notice">
      <div class="notice-title" v-text="noticeMain.title"></div>
      <div class="notice-time">{{noticeMain.updateTime|formatDate}}</div>
      <div class="notice-content" v-text="noticeContent"></div>
    </div>
  </div>
</template>

<script>
  import {
    formatDate
  } from "../common/date.js";
  import {
    getNotice_Axios
  } from './axios/api';
  export default {
    methods: {
      getNotice() {
        //获取公告
        getNotice_Axios().then(res => {
          console.log('response', res);
          this.noticeMain = res.data.data;
          this.noticeContent = this.noticeMain.content.replace(
            /<[^>]+>/g,
            ""
          );
        }).catch(err => {
          console.log('请求失败', err);
        })
      },
    },
    data() {
      return {
        noticeMain: '',
        noticeContent: '',
      }
    },
    filters: {
      formatDate(time) {
        var date = new Date(time);
        return formatDate(date, "yyyy-MM-dd");
        // return formatDate(date, "yyyy-MM-dd hh:mm");
      }
    },
    mounted() {
      this.getNotice();
    },

  }

</script>

<style lang="scss">
  .noticeAll {
    background: #fbf3d0;
    height: 100vh;
    .notice {
      margin: 2rem;

      .notice-title {
        font-size: 1.4rem;
        font-weight: bold;
        margin: 1rem;
      }
      .notice-time {
        text-align: right;
        margin: 0 1rem;
        font-size: 1.1rem;
        color: #999;
      }
      .notice-content {
        margin: 1rem;
        font-size: 1.3rem;
        text-align: left;
      }
    }
  }

</style>
